library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(factoextra)
## Loading required package: ggplot2
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(ggplot2)
library(cluster)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ lubridate 1.9.2 ✔ tibble 3.2.1
## ✔ purrr 1.0.1 ✔ tidyr 1.3.0
## ✔ readr 2.1.4
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggcorrplot)
library(writexl)
## Warning: package 'writexl' was built under R version 4.3.1
library(openxlsx)
## Warning: package 'openxlsx' was built under R version 4.3.1
library(PerformanceAnalytics)
## Warning: package 'PerformanceAnalytics' was built under R version 4.3.1
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
##
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
##
## ######################### Warning from 'xts' package ##########################
## # #
## # The dplyr lag() function breaks how base R's lag() function is supposed to #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
## # source() into this session won't work correctly. #
## # #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
## # dplyr from breaking base R's lag() function. #
## # #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
## # #
## ###############################################################################
##
## Attaching package: 'xts'
##
## The following objects are masked from 'package:dplyr':
##
## first, last
##
##
## Attaching package: 'PerformanceAnalytics'
##
## The following object is masked from 'package:graphics':
##
## legend
library(corrplot)
## corrplot 0.92 loaded
library(ggplot2)
library(car)
## Loading required package: carData
##
## Attaching package: 'car'
##
## The following object is masked from 'package:purrr':
##
## some
##
## The following object is masked from 'package:dplyr':
##
## recode
library(dplyr)
library(factoextra)
library(cluster)
library(simstudy)
## Warning: package 'simstudy' was built under R version 4.3.1
library(data.table)
## Warning: package 'data.table' was built under R version 4.3.1
##
## Attaching package: 'data.table'
##
## The following objects are masked from 'package:xts':
##
## first, last
##
## The following objects are masked from 'package:lubridate':
##
## hour, isoweek, mday, minute, month, quarter, second, wday, week,
## yday, year
##
## The following object is masked from 'package:purrr':
##
## transpose
##
## The following objects are masked from 'package:dplyr':
##
## between, first, last
library(tidyverse)
library(PerformanceAnalytics)
library(corrr)
## Warning: package 'corrr' was built under R version 4.3.1
#cargamos los datos con las variables que nos interesan
#df1 = data.frame(read.csv2('C:/Users/linfante/OneDrive/Documentos/MasterBigData/TFM/tfm_master_ds/1 - BackEnd/Datos/alimentos v3.csv', sep=','))
#df2 = data.frame(read.csv2('C:/Users/linfante/OneDrive/Documentos/MasterBigData/TFM/tfm_master_ds/1 - BackEnd/Datos/alimentos_vegan.csv', sep=','))
df = data.frame(read.csv2('C:/Users/linfante/OneDrive/Documentos/MasterBigData/TFM/tfm_master_ds/1 - BackEnd/Datos/alimentos v4.csv', sep=','))
#df <- df[,c("PRODUCT_NAME","PROTEINS_100G","CARBOHYDRATES_100G","FAT_100G","FIBER_100G","SALT_100G","SATURATED_FAT_100G","SUGARS_100G")]
df <- df[,c("PRODUCT_NAME","PROTEINS_100G","CARBOHYDRATES_100G","FAT_100G")]
PRODUCT_NAME <- df[,1]
# Filtrar las columnas que contienen el texto "_100G"
#columnas_filtradas <- grep("_100G", colnames(df))
#df <- df[, columnas_filtradas]
#df <- cbind(PRODUCT_NAME,df)
#Convertir a numerico todo
df_nuevo <- df %>%
mutate(across(where(is.character), type.convert, as.is = TRUE)) %>%
select_if(is.numeric)
## Warning: There was 1 warning in `mutate()`.
## ℹ In argument: `across(where(is.character), type.convert, as.is = TRUE)`.
## Caused by warning:
## ! The `...` argument of `across()` is deprecated as of dplyr 1.1.0.
## Supply arguments directly to `.fns` through an anonymous function instead.
##
## # Previously
## across(a:b, mean, na.rm = TRUE)
##
## # Now
## across(a:b, \(x) mean(x, na.rm = TRUE))
total <- as.data.frame(colSums(df_nuevo))
totalc <- as.data.frame(rowSums(df_nuevo))
totales <- colSums(df_nuevo)
# Seleccionar las columnas con un total mayor o igual a 5
#columnas_a_mantener <- totales >= 10000
# Eliminar las columnas con un total inferior a 30
#df_nuevo <- df_nuevo[, columnas_a_mantener]
PRODUCT_NAME <- df[,1]
df_nuevo <- cbind(PRODUCT_NAME,df_nuevo)
#elimina vectores fila nulos
df_nuevo$suma <- rowSums(df_nuevo[, c("PROTEINS_100G","CARBOHYDRATES_100G","FAT_100G")])
df_nuevo <- subset(df_nuevo, !(suma == 0))
df_nuevo <- df_nuevo[,c("PRODUCT_NAME","PROTEINS_100G","CARBOHYDRATES_100G","FAT_100G")]
df_nuevo <- na.omit(df_nuevo)
#filtros negativos
# Crear un vector con las palabras a buscar
palabras_a_eliminar <- c("SALSA DE SOJA","SAUCE SOJA", "SAUCE SOJA","BEBIDA DE SOJA", "YAOURT SOJA","YOGURT DE SOJA","CHOCOLAT","ARROZ Y SOJA","LECHE","MOUSSE","MILK","ACEITE","DESSERT","PAN SOJA","BOISSON SOJA", "GLACE","ML","SAUCE DE SOJA","SAUCE","SALSA","BIBEDA DE SOJA","LAIT SOJA","VIVESOY SOJA","LAIT DE SOJA","YAOURT","POSTRE","MUESLI","YOGUR","BEBIDA","MARGARINA","VINAIGRETTE","DRINK","SAUCE","BATIDO","LAIT","MAYONNAISE","CAFE","VANILLE","NATA","YOGURT")
# Crear una función que verifica si alguna de las palabras está presente en el texto
verificar_palabras <- function(texto, palabras) {
sapply(palabras, function(palabra) grepl(palabra, texto))
}
# Identificar las filas que contienen alguna de las palabras a eliminar
filas_a_eliminar <- apply(df_nuevo, 1, function(row) any(verificar_palabras(row["PRODUCT_NAME"], palabras_a_eliminar)))
# Eliminar las filas identificadas del dataframe original
df_nuevo1 <- df_nuevo[!filas_a_eliminar, ]
#df_nuevo2 <- df_nuevo1[,-1]
#Elimino los faltantes
df_nuevo1 <- df_nuevo1[complete.cases(df_nuevo1), ]
df_soja <- subset(df_nuevo1, grepl("soja", PRODUCT_NAME, ignore.case = TRUE)) ## Registros que contienen la palabra "soja"
df_seitan <- subset(df_nuevo1, grepl("seitan", PRODUCT_NAME, ignore.case = TRUE)) ## Registros que contienen la palabra "seitan"
df_tofu <- subset(df_nuevo1, grepl("tofu", PRODUCT_NAME, ignore.case = TRUE)) ## Registros que contienen la palabra "tofu"
df_tofu <- na.omit(df_tofu)
# Definir la función para eliminar valores atÃpicos basados en desviación estándar
remove_outliers <- function(data, column, sd_threshold = 2) {
data[abs(scale(data[[column]])) < sd_threshold, ]
}
# Eliminar valores atÃpicos en columna1 utilizando desviación estándar
df_soja <- remove_outliers(df_soja, "PROTEINS_100G")
df_soja <- remove_outliers(df_soja, "CARBOHYDRATES_100G")
df_soja <- remove_outliers(df_soja, "FAT_100G")
#df_soja <- remove_outliers(df_soja, "SUGARS_100G")
# Eliminar valores atÃpicos en columna1 utilizando desviación estándar
df_seitan <- remove_outliers(df_seitan, "PROTEINS_100G")
df_seitan <- remove_outliers(df_seitan, "CARBOHYDRATES_100G")
df_seitan <- remove_outliers(df_seitan, "FAT_100G")
#df_seitan <- remove_outliers(df_seitan, "SUGARS_100G")
# Eliminar valores atÃpicos en columna1 utilizando desviación estándar
df_tofu <- remove_outliers(df_tofu, "PROTEINS_100G")
df_tofu <- remove_outliers(df_tofu, "CARBOHYDRATES_100G")
df_tofu <- remove_outliers(df_tofu, "FAT_100G")
#df_tofu <- remove_outliers(df_tofu, "SUGARS_100G")
summary(df_soja)
## PRODUCT_NAME PROTEINS_100G CARBOHYDRATES_100G FAT_100G
## Length:2219 Min. : 0.00 Min. : 0.00 Min. : 0.000
## Class :character 1st Qu.: 3.40 1st Qu.: 3.30 1st Qu.: 2.000
## Mode :character Median : 6.70 Median : 8.90 Median : 4.800
## Mean :13.89 Mean :11.65 Mean : 7.118
## 3rd Qu.:18.00 3rd Qu.:15.00 3rd Qu.:10.000
## Max. :50.00 Max. :56.50 Max. :41.800
# Obtener las columnas cuantitativas del dataframe
columnas_cuantitativas <- sapply(df_soja, is.numeric)
# Crear un histograma para cada columna cuantitativa
for (columna in names(df_soja[columnas_cuantitativas])) {
plot_data <- df_soja[, columna]
p <- ggplot(data.frame(x = plot_data), aes(x)) +
geom_histogram(binwidth = 0.5, fill = "steelblue", color = "white") +
labs(title = paste("Histograma de", columna),
x = columna,
y = "Frecuencia")
print(p)
}
s_soja <- scale(df_soja[,-1])
s_soja1 <- as.data.frame(s_soja)
summary(s_soja)
## PROTEINS_100G CARBOHYDRATES_100G FAT_100G
## Min. :-0.9430 Min. :-1.0186 Min. :-1.0103
## 1st Qu.:-0.7122 1st Qu.:-0.7300 1st Qu.:-0.7264
## Median :-0.4882 Median :-0.2403 Median :-0.3290
## Mean : 0.0000 Mean : 0.0000 Mean : 0.0000
## 3rd Qu.: 0.2790 3rd Qu.: 0.2931 3rd Qu.: 0.4092
## Max. : 2.4514 Max. : 3.9222 Max. : 4.9231
# Obtener las columnas cuantitativas del dataframe
columnas_cuantitativas <- sapply(s_soja1, is.numeric)
# Crear un histograma para cada columna cuantitativa
for (columna in names(s_soja1[columnas_cuantitativas])) {
plot_data <- s_soja1[, columna]
p <- ggplot(data.frame(x = plot_data), aes(x)) +
geom_histogram(binwidth = 0.5, fill = "steelblue", color = "white") +
labs(title = paste("Histograma de", columna),
x = columna,
y = "Frecuencia")
print(p)
}
#total de cluster óptimos
elbow <- fviz_nbclust(x = s_soja, FUNcluster = kmeans, method = "wss", k.max = 15,
diss = get_dist(s_soja, method = "euclidean"), nstart = 25)
print(elbow)
#Clustering K-means
set.seed(123)
km_clusters <- kmeans(x=s_soja,centers=4,nstart=25)
fviz_cluster(object=km_clusters,data=s_soja,show.clust.cent = TRUE,
ellipse.type="euclid",star.plot=TRUE,repel=TRUE,
pointsize=0.5,outlier.color="darkred") +
labs(title ="Resultados clustering K-means") +
theme_bw() +
theme(legend.position = "none")
#Dedrograma
set.seed(101)
heculidea <- hclust(d = dist(x = s_soja, method = "euclidean"),
method = "complete")
fviz_dend(x=heculidea,cex=0.5,main = "Linkage completo",
sub="Distancia euclÃdea")+
theme(plot.title = element_text(hjust=0.5,size=15))
## Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as
## of ggplot2 3.3.4.
## ℹ The deprecated feature was likely used in the factoextra package.
## Please report the issue at <https://github.com/kassambara/factoextra/issues>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
#Resultados clustering K-means
require(cluster)
pam.res <- pam(s_soja, 4)
# Visualización
fviz_cluster(pam.res, geom = "point", ellipse.type = "norm",
show.clust.cent = TRUE,star.plot = TRUE)+
labs(title = "Resultados clustering K-means")+ theme_bw()
Con esta imagen se evidencia que hay cierto grado de conflicto entre los clusters, ya que tienen cierta área solapada entre ambos. Estas representaciones mezclan cluster y PCA, pero no indican el grado de representación de cada variable en cada uno de los componentes.
# PCA
pca <- prcomp(df_soja[,-1], scale=TRUE)
df_soja.pca <- pca$x
# Cluster over the three first PCA dimensions
kc <- kmeans(df_soja.pca[,1:3], 3)
fviz_pca_biplot(pca, label="var", habillage=as.factor(kc$cluster)) +
labs(color=NULL) + ggtitle("") +
theme(text = element_text(size = 15),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"),
legend.key = element_rect(fill = "white"))
summary(df_seitan)
## PRODUCT_NAME PROTEINS_100G CARBOHYDRATES_100G FAT_100G
## Length:629 Min. : 1.40 Min. : 0.000 Min. : 0.000
## Class :character 1st Qu.:16.00 1st Qu.: 5.200 1st Qu.: 1.600
## Mode :character Median :20.49 Median : 7.000 Median : 3.800
## Mean :20.15 Mean : 8.419 Mean : 5.194
## 3rd Qu.:25.00 3rd Qu.:11.000 3rd Qu.: 8.000
## Max. :36.00 Max. :24.400 Max. :17.400
# Obtener las columnas cuantitativas del dataframe
columnas_cuantitativas <- sapply(df_seitan, is.numeric)
# Crear un histograma para cada columna cuantitativa
for (columna in names(df_seitan[columnas_cuantitativas])) {
plot_data <- df_seitan[, columna]
p <- ggplot(data.frame(x = plot_data), aes(x)) +
geom_histogram(binwidth = 0.5, fill = "steelblue", color = "white") +
labs(title = paste("Histograma de", columna),
x = columna,
y = "Frecuencia")
print(p)
}
s_seitan <- scale(df_seitan[,-1])
s_seitan1 <- as.data.frame(s_seitan)
summary(s_seitan)
## PROTEINS_100G CARBOHYDRATES_100G FAT_100G
## Min. :-2.7208 Min. :-1.6559 Min. :-1.1841
## 1st Qu.:-0.6028 1st Qu.:-0.6331 1st Qu.:-0.8193
## Median : 0.0486 Median :-0.2790 Median :-0.3178
## Mean : 0.0000 Mean : 0.0000 Mean : 0.0000
## 3rd Qu.: 0.7029 3rd Qu.: 0.5078 3rd Qu.: 0.6397
## Max. : 2.2987 Max. : 3.1436 Max. : 2.7827
#Datos normalizados para el Seitán
# Obtener las columnas cuantitativas del dataframe
columnas_cuantitativas <- sapply(s_seitan1, is.numeric)
# Crear un histograma para cada columna cuantitativa
for (columna in names(s_seitan1[columnas_cuantitativas])) {
plot_data <- s_seitan1[, columna]
p <- ggplot(data.frame(x = plot_data), aes(x)) +
geom_histogram(binwidth = 0.5, fill = "steelblue", color = "white") +
labs(title = paste("Histograma de", columna),
x = columna,
y = "Frecuencia")
print(p)
}
s_seitan <- scale(df_seitan[,-1])
# total de cluster óptimos
elbow <- fviz_nbclust(x = s_seitan, FUNcluster = kmeans, method = "wss", k.max = 15,
diss = get_dist(s_seitan, method = "euclidean"), nstart = 25)
print(elbow)
set.seed(123)
km_clusters <- kmeans(x=s_seitan,centers=4,nstart=25)
fviz_cluster(object=km_clusters,data=s_seitan,show.clust.cent = TRUE,
ellipse.type="euclid",star.plot=TRUE,repel=TRUE,
pointsize=0.5,outlier.color="darkred") +
labs(title ="Resultados clustering K-means") +
theme_bw() +
theme(legend.position = "none")
set.seed(101)
heculidea <- hclust(d = dist(x = s_seitan, method = "euclidean"),
method = "complete")
fviz_dend(x=heculidea,cex=0.5,main = "Linkage completo",
sub="Distancia euclÃdea")+
theme(plot.title = element_text(hjust=0.5,size=15))
require(cluster)
pam.res <- pam(s_seitan, 4)
# Visualización
fviz_cluster(pam.res, geom = "point", ellipse.type = "norm",
show.clust.cent = TRUE,star.plot = TRUE)+
labs(title = "Resultados clustering K-means")+ theme_bw()
# Biplot PCA y K-Means para medir representatividad seitan
# PCA
pca <- prcomp(df_seitan[,-1], scale=TRUE)
df_seitan.pca <- pca$x
# Cluster over the three first PCA dimensions
kc <- kmeans(df_seitan.pca[,1:3], 3)
fviz_pca_biplot(pca, label="var", habillage=as.factor(kc$cluster)) +
labs(color=NULL) + ggtitle("") +
theme(text = element_text(size = 15),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"),
legend.key = element_rect(fill = "white"))
##### TOfu
summary(df_tofu)
## PRODUCT_NAME PROTEINS_100G CARBOHYDRATES_100G FAT_100G
## Length:2509 Min. : 0.50 Min. : 0.000 Min. : 0.00
## Class :character 1st Qu.: 7.90 1st Qu.: 1.300 1st Qu.: 5.00
## Mode :character Median :12.60 Median : 2.400 Median : 7.80
## Mean :11.78 Mean : 5.414 Mean : 8.18
## 3rd Qu.:15.20 3rd Qu.: 7.500 3rd Qu.:10.30
## Max. :23.60 Max. :27.429 Max. :21.80
# Obtener las columnas cuantitativas del dataframe
columnas_cuantitativas <- sapply(df_tofu, is.numeric)
# Crear un histograma para cada columna cuantitativa
for (columna in names(df_tofu[columnas_cuantitativas])) {
plot_data <- df_tofu[, columna]
p <- ggplot(data.frame(x = plot_data), aes(x)) +
geom_histogram(binwidth = 0.5, fill = "steelblue", color = "white") +
labs(title = paste("Histograma de", columna),
x = columna,
y = "Frecuencia")
print(p)
}
s_tofu <- scale(df_tofu[,-1])
s_tofu1 <- as.data.frame(s_tofu)
summary(s_tofu)
## PROTEINS_100G CARBOHYDRATES_100G FAT_100G
## Min. :-2.2874 Min. :-0.8833 Min. :-1.88626
## 1st Qu.:-0.7870 1st Qu.:-0.6712 1st Qu.:-0.73328
## Median : 0.1660 Median :-0.4918 Median :-0.08761
## Mean : 0.0000 Mean : 0.0000 Mean : 0.00000
## 3rd Qu.: 0.6932 3rd Qu.: 0.3402 3rd Qu.: 0.48888
## Max. : 2.3964 Max. : 3.5914 Max. : 3.14074
#Datos normalizados para el Tofu
# Obtener las columnas cuantitativas del dataframe
columnas_cuantitativas <- sapply(s_tofu1, is.numeric)
# Crear un histograma para cada columna cuantitativa
for (columna in names(s_tofu1[columnas_cuantitativas])) {
plot_data <- s_tofu1[, columna]
p <- ggplot(data.frame(x = plot_data), aes(x)) +
geom_histogram(binwidth = 0.5, fill = "steelblue", color = "white") +
labs(title = paste("Histograma de", columna),
x = columna,
y = "Frecuencia")
print(p)
}
s_tofu <- scale(df_tofu[,-1])
# total de cluster óptimos
elbow <- fviz_nbclust(x = s_tofu, FUNcluster = kmeans, method = "wss", k.max = 15,
diss = get_dist(s_tofu, method = "euclidean"), nstart = 25)
print(elbow)
set.seed(123)
km_clusters <- kmeans(x=s_tofu,centers=4,nstart=25)
fviz_cluster(object=km_clusters,data=s_tofu,show.clust.cent = TRUE,
ellipse.type="euclid",star.plot=TRUE,repel=TRUE,
pointsize=0.5,outlier.color="darkred") +
labs(title ="Resultados clustering K-means") +
theme_bw() +
theme(legend.position = "none")
set.seed(101)
heculidea <- hclust(d = dist(x = s_tofu, method = "euclidean"),
method = "complete")
fviz_dend(x=heculidea,cex=0.5,main = "Linkage completo",
sub="Distancia euclÃdea")+
theme(plot.title = element_text(hjust=0.5,size=15))
require(cluster)
pam.res <- pam(s_tofu, 4)
# Visualización
fviz_cluster(pam.res, geom = "point", ellipse.type = "norm",
show.clust.cent = TRUE,star.plot = TRUE)+
labs(title = "Resultados clustering K-means")+ theme_bw()
# Biplot PCA y K-Means para medir representatividad tofu
# PCA
pca <- prcomp(df_tofu[,-1], scale=TRUE)
df_tofu.pca <- pca$x
# Cluster over the three first PCA dimensions
kc <- kmeans(df_tofu.pca[,1:3], 3)
fviz_pca_biplot(pca, label="var", habillage=as.factor(kc$cluster)) +
labs(color=NULL) + ggtitle("") +
theme(text = element_text(size = 15),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"),
legend.key = element_rect(fill = "white"))
# Método no jerárquico CLARA basado en simulación y muestreo
clara_clusters <- clara(x = scale(df_soja[,-1]), k = 4, metric = "manhattan", stand = TRUE,
samples = 60, pamLike = TRUE)
clara_clusters$sample
## [1] "1013" "1032" "1345" "1576" "1597" "1737" "1796" "1830" "1884"
## [10] "2161" "2345" "2446" "2490" "2513" "2911" "3002" "3544" "3598"
## [19] "3635" "3991" "4055" "4178" "4223" "4297" "4299" "4402" "4698"
## [28] "5522" "5835" "6028" "6136" "6174" "6424" "6493" "6578" "6884"
## [37] "6978" "7006" "7525" "7552" "7633" "7672" "8437" "8631" "8671"
## [46] "9004" "9397" "10003"
clara_clusters$medoids
## PROTEINS_100G CARBOHYDRATES_100G FAT_100G
## 8671 -0.1011949 1.8234211 0.76401714
## 4178 0.1431987 -0.5813796 0.55109662
## 1345 -0.6782355 -0.3889956 -0.69803713
## 7552 2.3834738 0.3805407 0.06847676
clara_clusters$i.med
## [1] 1991 963 248 1771
clara_clusters$clustering
## 11 23 24 26 28 37 39 56 90 188 223 253 294
## 1 1 2 2 3 3 2 3 3 1 3 3 3
## 295 298 308 317 332 339 345 348 352 364 365 372 374
## 1 4 3 1 2 2 3 3 3 3 4 2 2
## 375 377 379 380 384 386 389 401 404 405 408 411 419
## 3 1 3 2 3 3 3 3 4 2 2 3 3
## 422 433 440 449 450 476 479 480 485 507 540 552 570
## 3 4 3 1 3 3 3 3 4 3 4 3 3
## 574 585 647 659 663 667 669 677 681 683 704 709 714
## 2 1 1 2 4 2 3 3 3 4 2 1 3
## 728 729 732 737 743 744 751 762 763 767 771 778 779
## 2 2 2 2 2 2 3 2 3 3 2 4 3
## 780 783 786 790 796 799 803 805 823 825 833 843 847
## 2 3 2 3 2 4 3 3 1 3 3 3 3
## 849 851 854 873 880 882 892 897 932 935 944 959 962
## 2 2 1 3 3 3 2 2 4 3 3 3 2
## 965 966 967 968 978 987 991 992 994 995 999 1000 1001
## 2 3 3 2 3 2 3 2 3 2 3 2 1
## 1008 1009 1010 1012 1013 1014 1018 1019 1023 1024 1025 1026 1029
## 1 2 2 2 1 3 3 3 2 2 2 2 2
## 1030 1032 1035 1037 1040 1041 1042 1047 1049 1054 1057 1058 1060
## 3 3 3 3 3 3 3 2 2 3 3 1 2
## 1062 1064 1066 1068 1072 1073 1074 1078 1079 1080 1081 1086 1089
## 2 2 3 1 3 2 2 2 3 3 2 3 2
## 1091 1092 1094 1095 1101 1103 1105 1110 1116 1117 1118 1122 1124
## 2 3 1 2 2 3 3 2 3 1 3 3 3
## 1129 1130 1131 1132 1134 1135 1136 1140 1141 1146 1147 1148 1153
## 3 2 1 1 2 3 2 3 2 2 1 3 3
## 1160 1165 1169 1172 1173 1175 1176 1179 1181 1184 1185 1186 1187
## 2 2 3 3 3 2 2 2 1 1 2 3 3
## 1188 1189 1192 1193 1197 1200 1208 1212 1214 1216 1219 1220 1227
## 2 2 2 3 3 3 3 3 3 3 2 3 3
## 1232 1233 1234 1238 1243 1245 1249 1250 1251 1252 1254 1256 1261
## 4 3 2 3 2 3 3 3 1 2 3 3 2
## 1264 1267 1268 1271 1272 1276 1281 1284 1285 1286 1294 1302 1307
## 2 2 2 2 1 3 1 3 3 3 3 3 3
## 1312 1315 1316 1318 1327 1328 1331 1333 1337 1338 1339 1342 1344
## 2 3 2 2 3 3 3 3 2 4 3 3 2
## 1345 1346 1348 1350 1354 1355 1356 1357 1364 1366 1367 1369 1374
## 3 2 3 2 3 3 3 3 3 3 3 3 3
## 1375 1376 1377 1378 1379 1381 1384 1385 1388 1390 1392 1393 1395
## 3 3 3 3 3 2 3 2 2 3 1 3 2
## 1396 1398 1400 1401 1402 1403 1404 1405 1406 1409 1410 1411 1414
## 3 2 3 3 3 3 3 4 3 3 2 3 3
## 1415 1417 1418 1419 1422 1423 1430 1432 1433 1435 1436 1438 1440
## 3 3 3 3 1 3 2 3 3 3 3 3 3
## 1441 1442 1444 1449 1452 1454 1455 1456 1458 1459 1460 1462 1464
## 2 3 3 3 3 1 2 3 2 3 3 3 3
## 1465 1467 1470 1471 1472 1473 1474 1476 1477 1481 1482 1484 1486
## 3 3 3 3 3 3 2 3 3 3 2 2 3
## 1487 1489 1490 1492 1494 1495 1497 1498 1500 1502 1504 1505 1507
## 3 3 3 3 2 2 3 3 2 1 3 3 1
## 1508 1510 1515 1516 1517 1523 1525 1526 1527 1528 1529 1530 1533
## 3 2 4 3 2 3 3 3 1 3 3 3 1
## 1535 1536 1537 1540 1543 1547 1548 1549 1551 1557 1558 1559 1560
## 1 2 3 3 1 3 3 4 3 3 3 3 2
## 1562 1564 1566 1567 1568 1570 1575 1576 1585 1588 1592 1593 1596
## 1 4 3 4 1 4 3 2 2 2 4 4 4
## 1597 1601 1608 1609 1620 1623 1624 1626 1629 1630 1631 1635 1640
## 3 4 2 3 4 2 4 2 2 4 1 3 3
## 1642 1645 1649 1650 1656 1659 1662 1666 1667 1669 1674 1677 1679
## 3 3 3 1 3 2 3 1 3 1 3 3 3
## 1680 1683 1684 1685 1688 1690 1691 1696 1698 1699 1700 1701 1708
## 2 2 2 2 2 3 2 3 1 2 3 3 3
## 1709 1711 1712 1713 1714 1721 1722 1723 1725 1726 1727 1728 1729
## 2 2 3 3 1 2 2 3 3 3 3 2 2
## 1734 1737 1741 1743 1746 1749 1751 1752 1758 1760 1761 1763 1778
## 3 1 2 3 1 3 1 3 3 2 3 2 2
## 1781 1782 1790 1793 1794 1796 1797 1801 1805 1810 1812 1814 1815
## 2 1 3 2 3 2 2 2 3 3 3 1 2
## 1816 1817 1818 1821 1823 1827 1828 1830 1831 1833 1836 1839 1845
## 3 3 1 2 3 3 3 3 2 3 3 3 2
## 1849 1853 1855 1857 1869 1873 1875 1876 1877 1878 1884 1885 1889
## 3 1 2 4 4 3 1 3 3 2 3 3 2
## 1892 1893 1898 1904 1907 1911 1916 1927 1928 1931 1940 1945 1948
## 3 3 2 3 1 3 3 1 1 2 1 1 1
## 1953 1962 1965 1966 1978 1988 1989 1990 1998 2003 2006 2009 2010
## 1 4 1 1 2 3 2 4 4 4 4 4 4
## 2011 2015 2019 2022 2024 2026 2033 2035 2037 2040 2041 2047 2048
## 2 4 4 1 4 1 4 1 4 1 4 4 4
## 2053 2055 2057 2058 2061 2062 2070 2075 2077 2085 2088 2093 2097
## 4 2 3 4 3 4 3 1 2 3 4 3 3
## 2099 2100 2103 2105 2106 2109 2119 2131 2133 2141 2143 2158 2161
## 4 3 4 2 2 3 2 2 4 3 3 3 2
## 2162 2165 2175 2177 2181 2182 2184 2193 2203 2204 2211 2219 2220
## 4 3 3 1 3 1 4 2 4 2 4 3 2
## 2223 2239 2242 2252 2261 2266 2268 2269 2271 2273 2274 2275 2277
## 2 3 3 3 3 2 4 2 3 3 4 2 3
## 2279 2288 2292 2294 2299 2300 2307 2312 2316 2320 2324 2325 2326
## 3 2 3 1 2 3 2 3 3 3 3 4 3
## 2328 2334 2335 2338 2344 2345 2350 2354 2360 2361 2363 2366 2370
## 3 1 2 4 3 4 4 2 2 4 2 4 3
## 2371 2373 2374 2384 2385 2386 2391 2392 2396 2398 2400 2409 2413
## 3 3 4 4 3 4 2 4 4 4 3 3 4
## 2422 2427 2429 2432 2437 2446 2452 2455 2457 2460 2462 2464 2465
## 4 3 4 1 2 2 4 1 1 3 2 3 4
## 2466 2467 2469 2473 2475 2476 2477 2483 2484 2488 2490 2491 2492
## 2 4 4 3 2 3 2 3 2 3 4 3 3
## 2495 2496 2497 2498 2502 2503 2509 2513 2520 2523 2525 2526 2529
## 4 4 4 4 2 3 2 2 4 4 3 4 4
## 2534 2536 2537 2539 2544 2548 2550 2555 2556 2558 2563 2564 2567
## 3 4 2 3 2 3 2 3 4 2 2 3 2
## 2574 2579 2580 2581 2585 2593 2597 2603 2604 2605 2609 2611 2618
## 3 4 4 3 4 1 4 4 2 2 4 2 2
## 2622 2625 2633 2635 2638 2665 2667 2677 2699 2733 2734 2740 2762
## 2 2 1 3 1 3 3 3 2 1 3 3 1
## 2775 2781 2792 2813 2838 2842 2850 2852 2877 2879 2880 2883 2893
## 4 3 2 4 1 3 2 3 3 3 3 1 3
## 2898 2902 2905 2911 2912 2914 2915 2916 2922 2932 2934 2935 2936
## 2 3 3 2 3 3 1 3 3 3 3 3 3
## 2951 2955 2958 2967 2971 2972 2977 2978 2985 2992 2996 3002 3003
## 3 3 3 2 3 3 3 2 3 2 2 1 3
## 3008 3011 3014 3016 3023 3026 3029 3033 3034 3037 3039 3041 3047
## 3 3 3 2 3 2 3 3 1 3 3 2 3
## 3054 3055 3056 3067 3069 3078 3080 3091 3092 3098 3100 3107 3108
## 3 3 2 3 3 2 3 2 2 3 2 1 2
## 3116 3119 3123 3126 3127 3134 3136 3139 3142 3143 3144 3146 3147
## 3 3 2 2 4 2 2 3 3 4 3 4 1
## 3149 3156 3160 3163 3165 3168 3178 3180 3181 3186 3187 3188 3190
## 4 1 4 3 3 4 3 1 4 1 2 2 4
## 3192 3196 3199 3200 3201 3215 3231 3239 3254 3260 3263 3265 3269
## 3 3 3 4 4 2 2 3 2 2 2 2 3
## 3276 3288 3292 3298 3299 3315 3321 3322 3323 3333 3334 3348 3356
## 2 3 2 4 3 3 3 3 2 1 2 1 3
## 3362 3379 3380 3395 3403 3406 3412 3419 3428 3433 3439 3445 3462
## 1 2 3 2 2 3 2 2 3 2 3 4 3
## 3465 3486 3491 3492 3493 3494 3498 3503 3504 3511 3516 3529 3534
## 3 2 4 2 2 3 2 2 2 3 3 3 3
## 3543 3544 3550 3553 3560 3562 3565 3567 3569 3571 3572 3573 3574
## 2 2 2 2 3 2 2 2 2 2 2 2 3
## 3576 3577 3579 3587 3588 3596 3598 3600 3605 3606 3608 3609 3610
## 2 1 2 3 3 3 2 3 1 3 2 2 2
## 3611 3613 3614 3619 3622 3623 3626 3628 3635 3640 3650 3659 3660
## 3 3 3 2 3 3 4 3 3 4 3 3 1
## 3664 3665 3670 3675 3680 3681 3689 3697 3705 3706 3707 3708 3714
## 2 4 3 3 2 3 1 3 3 3 4 2 2
## 3715 3718 3720 3728 3730 3731 3732 3736 3740 3742 3751 3756 3757
## 3 3 2 1 4 1 3 1 4 1 3 3 3
## 3764 3767 3769 3774 3775 3781 3791 3818 3820 3839 3874 3903 3911
## 3 3 3 3 4 1 1 3 2 1 3 1 2
## 3925 3927 3930 3934 3946 3953 3957 3960 3964 3969 3971 3975 3989
## 3 3 4 3 3 3 3 3 3 3 3 4 3
## 3990 3991 3992 4000 4007 4013 4014 4018 4020 4024 4030 4032 4033
## 3 2 3 3 3 1 3 2 1 3 1 3 3
## 4035 4039 4042 4044 4045 4051 4055 4062 4067 4069 4070 4071 4074
## 4 3 2 3 3 3 3 1 1 3 4 3 1
## 4078 4084 4096 4114 4132 4135 4141 4143 4145 4147 4149 4156 4170
## 1 4 3 1 1 3 4 2 2 2 4 1 3
## 4178 4180 4184 4187 4189 4196 4203 4206 4209 4210 4219 4220 4223
## 2 2 4 1 2 2 4 3 3 4 4 3 3
## 4233 4240 4246 4257 4271 4275 4278 4282 4288 4293 4297 4299 4307
## 3 2 2 3 4 4 3 4 3 1 2 3 4
## 4310 4317 4328 4329 4338 4344 4346 4350 4361 4363 4374 4375 4391
## 1 2 3 3 3 4 3 3 1 3 3 3 3
## 4402 4413 4414 4417 4425 4426 4430 4431 4444 4454 4458 4463 4469
## 4 1 2 2 4 3 2 3 3 1 4 4 1
## 4471 4473 4493 4498 4500 4516 4529 4531 4533 4538 4557 4562 4564
## 3 3 4 2 4 3 4 4 1 1 4 3 1
## 4567 4569 4573 4577 4579 4584 4586 4588 4592 4598 4603 4606 4612
## 2 3 1 3 3 2 2 3 3 1 3 2 3
## 4623 4628 4638 4652 4656 4657 4680 4686 4687 4688 4689 4698 4706
## 3 3 3 3 3 4 3 2 2 2 3 3 1
## 4707 4714 4715 4716 4727 4742 4751 4768 4774 4776 4784 4787 4792
## 3 2 3 3 3 3 2 4 2 3 2 2 4
## 4805 4814 4835 4841 4851 4855 4856 4861 4864 4868 4875 4877 4878
## 3 2 3 2 3 3 2 2 4 3 3 4 3
## 4894 4895 4902 4903 4907 4909 4912 4915 4918 4921 4928 4942 4962
## 4 2 2 2 3 3 3 4 4 1 3 2 2
## 4969 4972 4982 4984 4990 5038 5042 5075 5093 5109 5111 5120 5128
## 2 2 2 1 3 4 4 3 3 1 4 3 3
## 5131 5226 5249 5261 5273 5281 5294 5315 5316 5317 5318 5321 5325
## 3 1 3 3 1 1 3 3 3 3 1 4 2
## 5327 5338 5340 5342 5345 5346 5348 5351 5352 5353 5358 5359 5362
## 3 4 2 3 2 3 2 3 3 2 2 1 2
## 5375 5380 5392 5400 5406 5418 5420 5422 5441 5442 5451 5466 5487
## 4 2 3 2 3 1 2 2 3 4 2 2 3
## 5491 5498 5505 5507 5522 5534 5535 5559 5603 5650 5654 5660 5678
## 1 3 3 3 2 4 3 3 3 3 3 2 3
## 5679 5680 5682 5684 5689 5699 5705 5707 5709 5710 5720 5729 5730
## 3 2 3 1 2 3 3 3 3 3 2 4 2
## 5732 5733 5734 5735 5737 5740 5756 5757 5762 5775 5779 5784 5793
## 4 2 2 3 2 1 3 2 3 2 3 3 2
## 5796 5797 5799 5801 5804 5806 5808 5820 5822 5835 5836 5839 5840
## 3 2 3 3 3 3 3 3 1 3 3 3 2
## 5841 5851 5853 5856 5861 5864 5868 5878 5885 5900 5929 5931 5940
## 3 3 3 3 3 1 4 3 4 3 2 1 2
## 5950 5952 5962 5963 5973 5977 5978 5981 5984 5985 5987 5991 5992
## 1 3 2 3 2 1 2 3 3 2 1 3 3
## 5994 5995 6003 6004 6006 6007 6008 6010 6013 6019 6020 6023 6028
## 3 1 2 2 3 3 3 3 2 2 2 2 3
## 6029 6032 6033 6034 6037 6039 6040 6041 6042 6043 6045 6047 6049
## 2 2 3 2 3 3 3 4 2 2 3 3 3
## 6051 6058 6060 6061 6064 6065 6068 6069 6072 6074 6076 6078 6080
## 3 2 3 3 2 2 3 2 2 3 3 1 3
## 6084 6085 6087 6088 6090 6096 6098 6099 6100 6101 6102 6103 6104
## 2 1 2 3 3 1 2 3 2 2 3 2 1
## 6105 6107 6108 6112 6114 6115 6118 6120 6123 6127 6130 6131 6132
## 2 2 2 3 3 2 2 3 2 3 3 3 3
## 6133 6136 6137 6138 6140 6141 6147 6148 6150 6152 6153 6154 6157
## 3 3 2 3 3 3 3 2 2 1 2 4 2
## 6161 6163 6164 6171 6174 6175 6176 6177 6179 6183 6185 6186 6188
## 2 1 2 2 3 3 3 2 3 2 4 2 3
## 6189 6192 6200 6204 6207 6210 6211 6212 6217 6218 6219 6221 6223
## 2 3 2 3 2 3 1 2 3 3 2 3 3
## 6226 6227 6231 6232 6233 6236 6238 6239 6240 6242 6245 6249 6250
## 2 3 3 3 3 1 2 3 3 3 4 3 3
## 6251 6253 6254 6256 6258 6262 6263 6266 6271 6272 6274 6276 6278
## 3 2 3 3 3 2 1 3 2 3 3 3 3
## 6284 6285 6286 6287 6289 6292 6294 6303 6305 6306 6315 6323 6324
## 3 3 3 3 3 3 3 1 4 2 3 3 2
## 6328 6329 6330 6331 6332 6334 6336 6337 6339 6344 6346 6347 6350
## 1 3 3 4 1 3 2 3 3 2 2 3 1
## 6352 6355 6360 6362 6365 6370 6371 6377 6379 6380 6383 6386 6387
## 3 2 3 3 2 3 3 3 3 2 3 3 3
## 6388 6389 6391 6397 6399 6403 6404 6406 6407 6408 6409 6411 6416
## 3 3 3 3 3 3 3 2 3 2 2 3 3
## 6417 6418 6419 6420 6421 6424 6428 6430 6431 6434 6437 6438 6439
## 4 2 3 3 3 3 2 2 2 1 2 3 3
## 6440 6442 6443 6445 6446 6447 6448 6452 6453 6455 6458 6459 6464
## 2 3 3 3 2 2 2 3 3 3 1 2 3
## 6467 6469 6471 6474 6476 6477 6478 6482 6483 6484 6487 6488 6489
## 3 3 3 3 3 3 3 2 3 3 3 3 3
## 6491 6492 6493 6495 6496 6497 6498 6499 6500 6501 6504 6505 6507
## 3 3 3 2 3 3 3 3 2 3 3 3 4
## 6509 6512 6516 6517 6518 6521 6523 6525 6526 6527 6529 6531 6538
## 2 3 3 2 2 2 3 3 3 3 2 3 3
## 6539 6540 6541 6543 6544 6545 6549 6550 6551 6552 6553 6554 6555
## 3 2 3 2 2 2 3 3 3 3 3 3 3
## 6556 6557 6559 6560 6563 6564 6567 6574 6575 6576 6578 6583 6585
## 3 3 3 2 3 1 3 3 3 3 4 4 2
## 6586 6589 6590 6594 6598 6603 6607 6611 6614 6616 6620 6622 6624
## 3 4 4 2 2 3 3 2 2 3 2 1 3
## 6625 6627 6630 6632 6633 6639 6640 6649 6650 6652 6653 6656 6658
## 2 4 3 3 4 2 3 3 4 3 3 4 3
## 6664 6667 6668 6669 6672 6674 6677 6679 6681 6682 6685 6686 6693
## 2 4 3 4 2 3 3 3 2 2 1 4 3
## 6696 6698 6704 6705 6707 6710 6712 6715 6719 6730 6734 6736 6740
## 3 4 4 4 3 3 3 2 3 2 3 4 2
## 6750 6751 6752 6753 6754 6756 6758 6759 6760 6762 6763 6767 6770
## 2 3 3 2 3 2 2 1 3 1 2 1 2
## 6776 6777 6778 6784 6788 6789 6790 6792 6794 6795 6797 6801 6802
## 2 3 2 2 3 3 2 3 3 2 2 3 3
## 6805 6806 6809 6810 6811 6812 6813 6814 6820 6821 6824 6828 6832
## 3 3 3 3 3 2 3 3 3 2 3 3 3
## 6834 6835 6839 6841 6845 6847 6848 6849 6853 6857 6859 6860 6861
## 2 2 3 3 3 1 1 3 3 3 3 2 1
## 6862 6863 6864 6867 6870 6875 6876 6877 6879 6884 6885 6886 6889
## 2 2 2 2 3 3 2 3 3 3 2 2 3
## 6890 6892 6894 6896 6903 6904 6905 6910 6911 6912 6913 6920 6923
## 3 3 3 2 2 2 3 3 2 3 2 3 3
## 6925 6927 6930 6938 6942 6948 6951 6952 6957 6958 6967 6969 6972
## 3 2 3 3 1 2 3 3 3 2 2 2 4
## 6973 6976 6978 6986 6991 6996 7001 7003 7006 7008 7013 7016 7020
## 4 1 3 3 1 3 2 3 2 1 4 3 2
## 7023 7025 7034 7035 7042 7043 7047 7048 7049 7051 7058 7063 7064
## 3 2 4 2 3 4 4 2 4 3 4 3 4
## 7065 7066 7070 7071 7075 7082 7096 7101 7102 7111 7115 7120 7121
## 1 4 4 4 2 4 3 3 4 4 3 4 3
## 7122 7128 7131 7133 7137 7142 7143 7144 7147 7150 7165 7167 7175
## 4 4 2 4 3 4 1 4 4 3 2 1 3
## 7177 7181 7185 7186 7214 7230 7234 7240 7247 7250 7256 7257 7259
## 1 3 2 4 2 2 2 1 3 4 2 3 4
## 7272 7273 7281 7284 7286 7287 7289 7290 7296 7303 7305 7308 7315
## 4 3 2 2 3 2 2 1 2 4 3 3 4
## 7323 7324 7329 7330 7333 7337 7340 7342 7347 7349 7352 7355 7356
## 2 3 2 2 3 3 3 4 3 2 3 3 3
## 7362 7363 7369 7372 7374 7379 7381 7389 7391 7392 7395 7396 7412
## 3 3 3 3 3 3 3 3 3 3 3 3 3
## 7413 7422 7440 7443 7447 7451 7456 7460 7462 7470 7471 7473 7479
## 3 4 4 4 3 2 2 3 4 3 2 3 3
## 7480 7486 7487 7488 7490 7496 7501 7521 7525 7537 7541 7545 7546
## 3 4 3 2 3 4 4 4 4 3 3 4 3
## 7547 7550 7552 7555 7557 7559 7560 7567 7569 7570 7571 7574 7576
## 2 3 4 4 3 4 2 3 4 4 1 3 2
## 7579 7580 7582 7588 7591 7595 7596 7597 7599 7611 7617 7624 7633
## 2 2 2 4 3 4 3 4 2 3 2 2 2
## 7634 7640 7655 7656 7668 7671 7672 7677 7678 7680 7686 7703 7713
## 2 4 1 4 4 2 3 3 4 4 2 1 3
## 7717 7729 7741 7742 7745 7754 7756 7758 7771 7773 7776 7781 7786
## 1 3 1 2 1 2 1 1 1 4 3 1 3
## 7790 7792 7795 7796 7807 7810 7812 7815 7820 7827 7843 7887 7890
## 1 1 1 1 1 2 3 3 2 3 2 3 3
## 7907 7945 7946 7963 7964 7969 7970 7976 7983 7985 7996 7997 8004
## 3 2 1 3 2 3 3 3 3 3 3 2 3
## 8009 8016 8018 8022 8024 8025 8027 8031 8040 8044 8046 8048 8050
## 1 2 1 3 3 3 2 3 3 2 3 3 3
## 8058 8076 8078 8080 8087 8091 8092 8099 8105 8114 8131 8138 8141
## 2 3 3 3 3 3 2 2 2 3 3 3 2
## 8148 8154 8161 8167 8168 8176 8186 8189 8193 8195 8198 8201 8203
## 3 3 2 1 3 3 1 3 3 3 3 2 3
## 8206 8207 8209 8218 8224 8242 8249 8258 8259 8261 8265 8267 8281
## 3 4 2 4 3 2 3 2 2 1 1 2 2
## 8282 8288 8296 8299 8307 8313 8316 8327 8329 8331 8332 8336 8348
## 3 3 4 2 3 3 2 1 1 3 4 3 2
## 8355 8362 8363 8365 8366 8371 8375 8377 8381 8384 8392 8393 8409
## 4 3 2 2 2 3 2 3 1 3 2 2 3
## 8410 8416 8418 8423 8427 8432 8434 8437 8449 8459 8464 8466 8470
## 3 3 3 4 2 2 1 2 2 2 2 3 2
## 8475 8481 8483 8484 8496 8503 8512 8514 8517 8521 8525 8530 8547
## 3 3 3 3 3 1 3 2 2 3 2 2 4
## 8550 8554 8567 8570 8574 8577 8584 8586 8588 8600 8604 8606 8608
## 3 4 3 2 2 2 2 1 2 2 2 3 4
## 8609 8611 8612 8616 8617 8619 8620 8625 8627 8630 8631 8633 8635
## 2 2 2 2 2 3 2 2 3 2 2 3 2
## 8641 8643 8644 8647 8651 8655 8657 8660 8661 8663 8666 8667 8668
## 3 3 2 3 2 1 3 4 3 2 2 2 3
## 8669 8671 8676 8677 8680 8684 8687 8701 8702 8704 8706 8707 8708
## 3 1 1 3 2 2 3 3 1 1 3 3 2
## 8711 8714 8721 8724 8727 8731 8741 8759 8764 8786 8810 8815 8824
## 2 3 4 3 1 3 3 3 3 1 4 3 3
## 8835 8875 8879 8893 8916 8956 8961 8967 8969 8970 8972 8976 8977
## 3 4 3 2 3 3 3 3 3 3 1 3 3
## 8978 8981 8983 8984 8986 8991 9002 9003 9004 9007 9008 9016 9022
## 1 3 1 3 1 3 2 3 1 3 1 2 4
## 9025 9027 9029 9031 9034 9036 9040 9045 9048 9049 9052 9054 9055
## 2 3 2 1 3 2 4 2 3 3 3 3 4
## 9057 9060 9064 9070 9071 9072 9078 9089 9091 9093 9096 9100 9108
## 4 3 3 1 3 3 4 4 3 3 1 3 4
## 9110 9112 9116 9117 9119 9120 9129 9133 9136 9145 9153 9158 9173
## 4 1 4 2 3 3 3 4 2 3 3 4 2
## 9179 9180 9189 9195 9197 9201 9204 9216 9218 9226 9227 9229 9237
## 3 3 4 3 3 2 2 3 1 1 3 2 3
## 9238 9247 9260 9261 9262 9268 9271 9279 9282 9288 9295 9297 9300
## 3 3 3 1 1 4 4 2 4 3 4 3 3
## 9303 9304 9308 9318 9320 9335 9339 9340 9342 9349 9350 9353 9377
## 3 3 1 4 3 4 4 3 4 4 3 3 3
## 9387 9389 9390 9392 9394 9397 9406 9422 9427 9439 9449 9451 9453
## 4 3 4 2 1 1 3 4 1 3 4 3 3
## 9458 9477 9483 9487 9488 9507 9526 9532 9534 9536 9538 9541 9549
## 4 1 3 4 2 3 3 1 3 3 4 3 2
## 9555 9559 9561 9571 9572 9578 9579 9597 9598 9605 9609 9613 9619
## 2 3 1 1 4 4 3 1 3 1 3 4 3
## 9625 9634 9637 9640 9641 9643 9649 9655 9658 9669 9673 9675 9679
## 3 3 3 3 1 1 3 3 1 1 3 3 4
## 9683 9684 9685 9689 9711 9727 9752 9762 9775 9777 9783 9785 9798
## 3 3 1 1 3 3 3 1 2 3 2 3 1
## 9807 9828 9831 9834 9836 9843 9858 9860 9866 9867 9873 9875 9878
## 3 3 2 3 2 4 2 4 3 3 3 2 3
## 9880 9881 9887 9890 9892 9905 9909 9936 9943 9946 9952 9953 9965
## 3 2 3 2 4 3 3 4 3 3 1 3 2
## 9970 9972 9975 9991 9994 9996 10000 10003 10004
## 2 3 3 3 1 2 4 1 3
table(clara_clusters$clustering)
##
## 1 2 3 4
## 249 611 1074 285
fviz_cluster(object = clara_clusters, ellipse.type = "t", geom = "point",
pointsize = 1.5) + theme_bw() +
labs(title = "Resultados clustering CLARA") +
theme(legend.position = "none")
clara_clusters <- clara(x = scale(df_seitan[,-1]), k = 3, metric = "manhattan", stand = TRUE,
samples = 60, pamLike = TRUE)
clara_clusters$sample
## [1] "473" "816" "824" "1304" "2172" "2207" "2215" "2535" "2952" "3138"
## [11] "3267" "3833" "3838" "3855" "3872" "4212" "4309" "4539" "4789" "5874"
## [21] "5902" "5906" "6144" "6265" "6322" "7085" "7213" "8185" "8196" "8230"
## [31] "8674" "8816" "8818" "8826" "8836" "8922" "8937" "8941" "9104" "9155"
## [41] "9274" "9310" "9370" "9452" "9607" "9801"
clara_clusters$medoids
## PROTEINS_100G CARBOHYDRATES_100G FAT_100G
## 1304 -0.02248502 -0.2593732 -0.8193032
## 7213 0.77541035 -0.2987133 1.0728682
## 3267 -0.89291633 1.2945632 1.0956655
clara_clusters$i.med
## [1] 86 426 177
clara_clusters$clustering
## 16 20 29 32 38 104 105 114 131 133 135 138 147 262 318 368
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## 385 455 471 472 473 490 513 517 533 541 558 568 569 571 572 581
## 2 1 1 1 1 1 1 1 1 3 3 1 1 3 3 2
## 592 597 673 700 719 753 765 809 816 824 828 829 845 857 871 872
## 1 1 2 2 2 3 3 1 1 1 1 1 1 1 1 1
## 891 899 900 902 903 904 905 906 909 910 915 916 918 920 922 923
## 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## 926 933 934 937 939 942 947 948 952 957 982 993 1036 1151 1158 1170
## 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 3
## 1209 1240 1247 1265 1277 1304 1336 1351 1361 1368 1421 1622 1881 2036 2060 2078
## 3 3 3 3 3 1 1 2 1 2 1 3 3 1 3 1
## 2081 2129 2132 2135 2172 2178 2189 2190 2196 2207 2215 2231 2233 2234 2245 2255
## 1 2 1 3 1 1 2 2 1 2 2 2 2 2 2 1
## 2263 2367 2424 2436 2450 2451 2458 2459 2463 2489 2500 2504 2505 2535 2543 2547
## 2 2 3 2 2 2 2 1 2 2 2 2 2 2 2 2
## 2557 2560 2570 2576 2630 2664 2697 2716 2749 2774 2891 2900 2910 2928 2930 2945
## 2 1 2 3 3 1 3 3 1 1 1 1 1 1 1 3
## 2952 2973 2983 3012 3017 3032 3062 3085 3088 3094 3096 3102 3103 3111 3112 3128
## 2 1 3 1 1 3 1 1 1 1 1 1 3 1 1 1
## 3130 3133 3138 3153 3154 3155 3161 3173 3175 3176 3177 3179 3191 3193 3194 3211
## 1 1 1 3 1 1 2 1 1 2 1 1 3 1 3 1
## 3267 3278 3346 3463 3482 3509 3522 3604 3643 3646 3666 3743 3746 3750 3760 3765
## 3 2 2 3 1 1 1 1 2 1 1 1 3 1 1 1
## 3771 3779 3784 3786 3787 3789 3794 3797 3805 3811 3813 3814 3816 3817 3833 3836
## 1 1 2 1 1 3 1 1 1 1 3 2 1 1 2 1
## 3838 3840 3844 3845 3846 3848 3849 3855 3861 3862 3864 3865 3870 3872 3876 3880
## 3 1 1 1 1 1 1 1 2 1 1 1 3 1 2 1
## 3883 3890 3896 3900 3907 3917 3924 3929 3933 3937 3941 3942 3944 3959 3998 4025
## 1 1 1 1 1 3 1 1 2 1 2 2 1 1 1 1
## 4031 4047 4053 4073 4087 4094 4098 4099 4109 4117 4118 4120 4137 4139 4140 4160
## 1 3 1 2 2 3 1 1 1 3 3 1 3 1 1 1
## 4162 4167 4173 4174 4177 4190 4205 4212 4218 4222 4229 4230 4236 4252 4260 4262
## 1 3 1 3 1 1 1 1 1 1 1 1 3 3 1 1
## 4266 4272 4281 4291 4292 4300 4306 4309 4313 4316 4318 4320 4323 4326 4327 4343
## 1 1 2 1 3 1 1 1 1 3 2 1 3 1 1 2
## 4351 4360 4362 4369 4383 4397 4401 4403 4405 4419 4439 4440 4446 4470 4474 4484
## 3 1 3 3 3 1 3 2 2 3 2 2 3 2 2 1
## 4513 4527 4539 4552 4575 4580 4731 4748 4789 4825 4881 4983 5121 5196 5211 5214
## 1 1 1 1 2 1 1 2 2 3 1 1 1 2 1 1
## 5239 5293 5295 5297 5372 5373 5377 5388 5390 5398 5403 5404 5447 5464 5465 5467
## 1 1 1 1 1 2 2 3 2 1 2 2 1 1 1 1
## 5470 5477 5495 5511 5520 5521 5529 5541 5542 5544 5567 5577 5587 5594 5596 5614
## 2 1 3 1 2 2 2 1 1 2 3 2 1 1 1 3
## 5783 5785 5807 5811 5812 5818 5819 5831 5859 5867 5869 5871 5873 5874 5875 5876
## 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1
## 5877 5879 5882 5883 5888 5891 5894 5896 5899 5901 5902 5906 5908 5909 5912 5913
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## 5914 5915 5916 5917 5922 5925 5930 5934 5939 5959 5961 5970 5998 6050 6056 6144
## 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 1
## 6257 6265 6300 6309 6318 6322 6327 6340 6354 6394 6410 6546 6665 6722 6738 6955
## 1 3 1 3 3 3 3 3 3 1 2 2 1 1 1 1
## 6971 7032 7085 7104 7114 7184 7195 7198 7208 7213 7215 7227 7243 7246 7254 7265
## 3 3 3 1 1 2 2 1 1 2 1 2 1 1 2 2
## 7268 7275 7302 7306 7330 7341 7376 7424 7476 7503 7519 7529 7533 7535 7536 7542
## 2 2 2 2 3 3 3 3 1 1 2 2 2 2 2 2
## 7551 7573 7577 7583 7600 7631 7642 7644 7645 7654 7663 7665 7679 7684 7685 7735
## 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3
## 7766 7806 7931 7952 7960 7962 7990 8029 8052 8057 8070 8084 8101 8160 8170 8180
## 1 2 3 1 1 3 1 1 1 3 1 1 1 1 2 1
## 8181 8184 8185 8190 8196 8197 8199 8221 8222 8226 8230 8231 8233 8234 8251 8270
## 1 1 1 3 1 1 3 1 3 1 1 1 3 1 1 1
## 8302 8310 8317 8400 8599 8622 8653 8659 8674 8710 8723 8736 8738 8744 8745 8747
## 3 1 3 2 3 1 2 1 2 1 1 3 1 3 1 1
## 8750 8753 8767 8774 8779 8780 8787 8793 8796 8805 8806 8816 8818 8825 8826 8829
## 1 3 1 1 2 1 1 1 1 1 1 1 1 1 3 1
## 8832 8833 8836 8838 8840 8841 8842 8845 8848 8850 8851 8853 8854 8860 8874 8877
## 2 2 2 1 2 1 1 1 1 3 1 1 3 1 1 1
## 8889 8895 8901 8904 8906 8922 8924 8927 8937 8941 8943 8950 8952 9046 9058 9085
## 1 1 1 1 1 1 1 3 1 2 2 1 1 2 1 1
## 9104 9125 9141 9146 9154 9155 9156 9162 9163 9178 9181 9182 9188 9191 9192 9217
## 3 3 1 1 3 2 3 1 1 3 1 1 1 1 1 1
## 9222 9234 9236 9249 9257 9258 9274 9283 9292 9293 9296 9309 9310 9326 9344 9345
## 3 1 3 1 1 1 3 2 1 3 3 2 2 1 3 1
## 9355 9370 9393 9402 9404 9407 9409 9411 9429 9436 9446 9450 9452 9464 9468 9475
## 3 3 2 3 1 1 2 3 1 2 2 1 1 2 3 3
## 9495 9497 9501 9506 9516 9521 9527 9528 9563 9580 9583 9593 9607 9616 9621 9678
## 2 3 1 1 2 1 1 1 1 2 2 3 2 2 1 1
## 9773 9789 9800 9801 9833
## 1 1 2 2 2
table(clara_clusters$clustering)
##
## 1 2 3
## 377 137 115
fviz_cluster(object = clara_clusters, ellipse.type = "t", geom = "point",
pointsize = 1.5) + theme_bw() +
labs(title = "Resultados clustering CLARA") +
theme(legend.position = "none")
df_tofu <- na.omit(df_tofu)
clara_clusters <- clara(x = scale(df_tofu[,-1]), k = 3, metric = "manhattan", stand = TRUE,
samples = 60, pamLike = TRUE)
clara_clusters$sample
## [1] "34" "218" "275" "506" "601" "1431" "1943" "1955" "1984" "2155"
## [11] "2194" "2510" "2741" "3547" "3559" "3717" "3881" "3940" "4679" "5034"
## [21] "5084" "5207" "5222" "5228" "5397" "5473" "5550" "5551" "5633" "5711"
## [31] "5803" "6975" "6995" "7197" "7280" "7368" "7612" "7658" "7973" "8121"
## [41] "8404" "8856" "8938" "9177" "9248" "9502"
clara_clusters$medoids
## PROTEINS_100G CARBOHYDRATES_100G FAT_100G
## 1431 0.6526350 -0.6222919 0.09686495
## 5711 -0.9897297 1.8411453 -0.06455252
## 5397 -0.7189840 -0.4994559 -0.80110451
clara_clusters$i.med
## [1] 461 1553 1428
clara_clusters$clustering
## 3 4 6 7 8 13 18 19 22 31 33 34 35
## 1 2 1 2 1 3 3 1 1 1 2 1 3
## 41 42 43 48 49 51 54 55 57 58 59 60 61
## 3 3 3 3 3 2 1 1 2 2 1 3 2
## 62 63 65 66 67 68 69 70 71 72 74 76 77
## 3 1 3 3 3 1 3 3 3 1 3 3 3
## 81 84 85 86 87 88 89 91 92 93 94 96 98
## 1 2 3 3 3 3 1 1 1 3 3 1 3
## 100 102 106 107 108 109 110 112 113 115 116 117 118
## 3 3 3 1 1 2 3 1 3 1 2 2 3
## 119 120 122 123 124 125 126 127 128 129 132 134 137
## 3 3 2 1 2 2 2 3 3 3 3 1 3
## 139 141 142 143 144 146 149 152 153 155 156 158 159
## 1 3 2 2 3 1 2 3 3 1 2 3 1
## 163 164 166 167 168 171 173 175 177 178 180 184 187
## 1 1 3 1 3 1 3 1 3 1 3 3 1
## 189 190 191 192 193 194 195 196 197 199 201 202 205
## 1 3 2 2 1 3 3 1 3 1 1 1 1
## 206 208 209 212 215 216 217 218 220 221 222 224 225
## 1 1 1 1 1 2 1 1 1 3 1 1 1
## 228 229 231 234 236 237 238 241 242 243 244 245 248
## 1 1 3 3 3 3 3 3 3 3 3 3 3
## 250 251 252 254 256 257 259 260 263 264 265 267 268
## 1 3 3 3 3 3 1 1 3 3 3 1 2
## 269 270 271 272 274 275 276 277 278 283 290 297 302
## 3 3 3 1 3 3 3 3 3 3 3 3 3
## 303 306 310 311 313 315 316 320 321 322 323 324 330
## 3 3 2 3 3 3 3 2 1 3 3 3 2
## 333 334 335 336 350 351 353 355 356 358 361 363 369
## 3 3 3 3 3 2 3 3 1 3 3 1 1
## 382 383 390 392 394 397 399 402 409 414 418 423 424
## 2 2 3 3 1 3 2 1 1 3 3 1 1
## 425 430 431 434 435 436 445 448 453 456 457 460 461
## 3 2 1 3 1 3 2 2 1 3 1 3 3
## 465 467 469 478 483 488 489 492 495 496 499 500 503
## 3 2 1 3 3 3 3 1 3 1 2 1 3
## 505 506 509 510 511 516 518 522 525 526 527 528 530
## 3 3 3 1 3 2 1 2 1 3 3 3 3
## 534 535 536 537 538 543 544 546 548 549 554 555 559
## 3 1 3 3 2 1 2 1 2 3 1 1 1
## 560 562 565 572 576 577 579 580 583 584 587 589 590
## 3 1 2 2 1 3 3 2 3 3 1 3 1
## 595 596 598 600 601 603 604 605 606 608 609 610 614
## 2 3 1 3 1 1 3 3 2 2 3 2 2
## 618 619 620 621 623 624 626 627 628 630 631 633 634
## 2 1 2 1 3 1 2 3 3 2 3 3 3
## 635 636 637 638 645 650 651 653 655 656 657 660 661
## 2 3 1 1 2 3 1 1 1 1 1 2 1
## 668 670 671 674 676 679 680 682 685 691 692 693 697
## 3 2 3 1 2 3 2 3 1 1 3 3 1
## 698 699 700 703 718 721 726 733 736 738 740 746 747
## 3 3 1 3 1 1 1 3 3 1 1 3 1
## 752 755 756 757 761 769 773 782 785 792 795 800 801
## 3 3 1 1 2 3 3 1 3 3 1 1 1
## 802 804 806 807 808 810 813 818 819 821 826 827 830
## 1 2 1 1 1 1 1 1 1 1 1 3 1
## 831 838 842 846 848 862 864 866 870 874 878 883 885
## 1 2 2 1 3 3 1 2 1 3 1 1 1
## 888 889 890 893 907 914 921 928 936 943 945 949 953
## 1 1 1 1 1 2 3 1 3 1 1 1 1
## 954 958 960 961 964 969 972 974 976 986 988 989 990
## 1 1 1 3 1 1 3 1 1 1 1 1 1
## 1006 1011 1016 1034 1038 1045 1048 1052 1053 1061 1063 1065 1069
## 1 1 1 1 1 1 2 3 1 2 1 1 2
## 1071 1075 1076 1082 1087 1088 1090 1093 1109 1120 1123 1125 1127
## 2 1 2 3 3 2 1 1 3 2 3 1 1
## 1157 1174 1177 1183 1205 1207 1213 1217 1218 1223 1230 1236 1241
## 3 3 1 2 3 2 1 1 1 3 2 1 2
## 1242 1243 1244 1258 1260 1269 1273 1274 1280 1287 1290 1300 1309
## 1 1 3 3 3 3 1 2 1 1 1 1 1
## 1310 1313 1317 1397 1427 1431 1443 1468 1494 1534 1538 1541 1542
## 2 1 1 1 2 1 2 3 1 2 3 1 1
## 1550 1572 1578 1598 1599 1600 1602 1605 1606 1612 1613 1614 1617
## 1 1 3 1 1 1 2 3 1 3 2 2 1
## 1621 1633 1637 1638 1643 1646 1648 1651 1653 1655 1657 1658 1663
## 1 1 2 2 1 3 1 1 1 1 2 1 2
## 1664 1670 1671 1672 1673 1678 1702 1720 1735 1766 1771 1772 1777
## 1 1 1 1 2 1 3 2 1 2 1 2 1
## 1807 1808 1815 1825 1832 1837 1838 1841 1847 1848 1850 1852 1858
## 1 1 1 1 1 1 1 1 2 2 1 2 3
## 1861 1863 1867 1874 1890 1897 1912 1915 1919 1923 1925 1929 1936
## 2 3 2 2 2 2 1 1 1 3 3 1 3
## 1943 1944 1947 1954 1955 1958 1959 1960 1968 1969 1970 1973 1974
## 2 3 2 1 2 3 1 1 2 3 1 1 2
## 1982 1983 1984 1993 1995 2008 2018 2023 2027 2032 2039 2043 2045
## 3 3 2 3 3 1 3 3 2 2 1 1 3
## 2049 2056 2063 2067 2072 2108 2111 2112 2117 2120 2121 2122 2123
## 1 3 3 1 1 1 1 1 1 1 1 1 2
## 2126 2127 2134 2136 2138 2139 2140 2144 2146 2149 2152 2154 2155
## 1 1 3 1 1 1 1 3 1 1 1 2 1
## 2156 2157 2159 2160 2163 2164 2166 2167 2169 2170 2171 2173 2174
## 1 1 1 2 1 1 1 2 1 1 2 1 1
## 2176 2179 2180 2183 2186 2187 2188 2191 2194 2198 2199 2200 2202
## 2 3 2 2 1 1 1 1 3 1 1 1 1
## 2205 2206 2210 2214 2221 2224 2228 2230 2232 2238 2240 2241 2243
## 2 1 1 1 1 2 1 1 1 1 1 1 1
## 2244 2246 2248 2249 2250 2251 2253 2259 2265 2272 2276 2280 2284
## 1 3 2 1 1 3 1 1 1 1 1 1 1
## 2285 2290 2291 2298 2301 2302 2304 2306 2310 2315 2317 2318 2321
## 2 1 1 1 1 3 3 1 2 1 1 1 1
## 2322 2323 2327 2329 2336 2339 2342 2343 2347 2349 2352 2353 2355
## 3 1 1 1 1 3 1 1 1 1 1 1 1
## 2357 2359 2365 2372 2379 2380 2382 2388 2389 2390 2393 2394 2397
## 1 3 1 1 1 1 1 1 1 1 1 1 1
## 2402 2404 2405 2406 2407 2408 2411 2412 2414 2419 2420 2421 2433
## 1 1 1 1 1 1 1 1 1 1 1 1 1
## 2435 2442 2443 2445 2447 2461 2470 2472 2481 2482 2499 2501 2506
## 1 1 1 1 1 1 3 1 3 1 1 1 1
## 2508 2510 2514 2515 2516 2519 2528 2530 2538 2540 2549 2554 2561
## 1 1 1 1 1 1 1 1 1 1 1 3 3
## 2569 2573 2576 2578 2583 2586 2590 2591 2592 2598 2599 2601 2602
## 1 1 1 1 2 1 3 1 1 1 1 1 2
## 2606 2612 2613 2616 2621 2626 2628 2640 2650 2656 2665 2673 2676
## 1 1 1 1 3 2 2 3 2 1 3 3 3
## 2692 2700 2707 2708 2709 2712 2723 2729 2737 2739 2741 2746 2750
## 1 3 1 1 2 3 3 1 2 3 2 1 3
## 2752 2753 2754 2760 2763 2768 2769 2773 2778 2780 2786 2790 2803
## 1 2 1 1 1 1 1 1 1 2 2 1 3
## 2804 2805 2810 2811 2814 2816 2819 2825 2826 2829 2834 2836 2839
## 2 1 1 1 2 1 1 3 1 2 1 2 3
## 2847 2863 2864 2867 2886 2899 2901 2941 2949 2969 2976 2979 3004
## 1 3 2 1 1 3 3 1 1 1 1 3 1
## 3021 3025 3061 3074 3076 3087 3104 3105 3106 3122 3129 3137 3140
## 1 1 1 1 3 1 1 3 1 1 3 1 1
## 3152 3172 3174 3202 3204 3205 3206 3208 3209 3214 3222 3223 3224
## 3 1 3 1 1 1 1 1 3 3 1 1 1
## 3227 3229 3234 3236 3238 3241 3250 3251 3262 3264 3271 3272 3277
## 1 1 1 1 1 1 1 1 2 1 3 2 1
## 3294 3297 3306 3308 3309 3316 3327 3329 3332 3335 3340 3342 3360
## 1 1 1 1 1 1 1 2 3 1 1 1 1
## 3366 3375 3390 3401 3405 3422 3430 3431 3434 3441 3447 3451 3454
## 1 1 3 1 1 1 1 1 2 3 3 2 3
## 3455 3458 3459 3460 3471 3474 3484 3495 3496 3499 3515 3528 3530
## 2 1 3 1 2 2 1 1 1 1 3 1 2
## 3531 3536 3539 3545 3547 3548 3549 3551 3552 3555 3556 3557 3558
## 1 1 1 3 2 1 2 1 1 1 1 1 1
## 3559 3561 3566 3568 3570 3578 3580 3581 3582 3583 3585 3589 3590
## 2 2 1 1 2 1 3 1 1 3 2 1 2
## 3591 3593 3594 3595 3597 3599 3606 3607 3615 3616 3617 3618 3621
## 3 3 1 1 2 2 3 1 1 1 1 1 1
## 3627 3629 3633 3636 3645 3647 3648 3669 3671 3674 3683 3702 3703
## 2 3 1 3 1 1 1 3 1 1 1 1 1
## 3717 3719 3723 3745 3748 3749 3752 3753 3755 3758 3761 3772 3780
## 1 3 1 3 2 2 1 1 2 1 2 1 1
## 3782 3783 3789 3793 3798 3800 3803 3806 3808 3809 3819 3821 3822
## 2 1 1 2 1 1 1 2 1 2 1 1 3
## 3823 3824 3826 3827 3830 3831 3832 3834 3835 3838 3841 3842 3847
## 1 1 1 1 1 2 1 3 3 1 1 3 1
## 3850 3851 3852 3853 3854 3856 3857 3858 3859 3866 3867 3868 3871
## 1 1 1 1 1 3 1 1 1 1 1 1 2
## 3877 3879 3881 3884 3885 3886 3887 3891 3892 3893 3894 3895 3897
## 1 1 1 1 1 1 2 1 1 1 1 1 1
## 3898 3899 3901 3904 3906 3908 3910 3914 3922 3923 3926 3931 3940
## 1 3 1 2 1 1 3 1 2 1 1 2 3
## 3941 3942 3950 3955 3962 3973 4002 4009 4017 4023 4027 4052 4058
## 1 1 3 3 1 1 1 1 3 3 3 3 3
## 4076 4079 4089 4090 4091 4093 4102 4104 4105 4107 4108 4110 4112
## 3 1 3 1 1 1 1 1 1 1 2 1 1
## 4116 4124 4125 4128 4130 4133 4134 4136 4142 4146 4154 4157 4161
## 1 2 1 3 1 3 2 2 1 2 3 3 1
## 4163 4165 4166 4174 4175 4179 4181 4183 4185 4188 4191 4192 4193
## 1 1 2 2 3 2 2 2 2 3 3 3 1
## 4195 4198 4204 4211 4213 4216 4217 4231 4235 4242 4243 4254 4255
## 1 1 3 2 1 3 2 2 2 3 1 1 1
## 4265 4268 4273 4277 4279 4283 4284 4286 4287 4289 4295 4298 4301
## 2 1 1 2 3 1 1 2 2 1 2 1 2
## 4302 4308 4314 4318 4319 4321 4325 4330 4333 4334 4336 4341 4347
## 1 2 2 1 2 2 1 2 2 1 2 1 2
## 4349 4351 4355 4356 4359 4366 4367 4373 4381 4387 4388 4389 4390
## 2 2 2 2 3 2 2 1 2 1 1 1 1
## 4394 4395 4396 4398 4400 4404 4407 4408 4420 4421 4422 4427 4435
## 3 2 1 1 1 2 1 3 1 1 2 2 2
## 4438 4443 4447 4453 4459 4460 4466 4472 4475 4485 4499 4501 4502
## 1 2 2 2 2 1 3 1 1 1 1 2 1
## 4506 4507 4511 4512 4520 4521 4522 4525 4532 4534 4535 4544 4549
## 1 1 1 1 3 1 1 1 1 2 3 1 1
## 4551 4558 4560 4565 4571 4572 4583 4604 4620 4624 4646 4648 4649
## 1 3 2 3 1 2 3 1 1 1 1 1 1
## 4661 4667 4670 4677 4679 4682 4683 4685 4690 4692 4695 4699 4702
## 3 3 2 3 1 3 3 2 3 1 1 3 3
## 4709 4718 4719 4721 4722 4730 4732 4735 4745 4747 4750 4759 4763
## 1 1 3 2 2 3 1 1 3 1 1 3 3
## 4765 4772 4781 4785 4788 4793 4796 4799 4803 4807 4819 4826 4830
## 3 3 1 3 3 3 1 3 3 3 3 1 1
## 4832 4834 4837 4838 4839 4844 4845 4846 4847 4849 4850 4854 4861
## 1 1 1 1 1 3 1 2 2 1 3 3 1
## 4862 4863 4866 4869 4880 4883 4884 4886 4890 4892 4893 4896 4897
## 1 2 2 1 2 3 2 1 1 1 1 3 1
## 4901 4906 4910 4914 4917 4922 4924 4930 4933 4936 4937 4938 4941
## 1 1 1 1 1 1 3 1 1 1 3 1 1
## 4945 4949 4954 4956 4960 4964 4968 4970 4973 4976 4978 4980 4985
## 1 1 2 1 3 1 3 1 2 1 3 1 3
## 4987 4988 4989 4991 4997 4999 5001 5003 5004 5005 5006 5008 5011
## 3 2 3 2 3 3 1 2 1 1 3 1 3
## 5012 5013 5014 5015 5016 5017 5019 5020 5022 5023 5024 5027 5030
## 1 2 1 3 1 3 3 3 2 1 3 1 2
## 5031 5033 5034 5040 5044 5045 5047 5048 5049 5050 5052 5054 5055
## 2 2 3 3 3 3 2 3 3 1 1 3 3
## 5056 5058 5059 5063 5067 5068 5069 5070 5071 5078 5079 5080 5081
## 3 2 3 2 3 3 2 1 3 3 3 2 2
## 5082 5083 5084 5085 5087 5090 5095 5097 5098 5099 5102 5104 5105
## 3 3 3 3 2 3 1 3 2 1 2 3 3
## 5108 5112 5117 5123 5125 5126 5127 5130 5135 5138 5142 5147 5151
## 1 1 1 3 1 1 3 1 1 3 3 3 3
## 5152 5153 5155 5156 5158 5163 5165 5166 5168 5171 5176 5177 5179
## 1 1 1 1 1 1 3 1 1 1 3 1 1
## 5180 5183 5184 5187 5188 5189 5192 5195 5197 5200 5201 5202 5203
## 3 3 3 1 1 2 1 3 1 1 1 3 1
## 5205 5206 5207 5208 5210 5212 5213 5215 5217 5218 5219 5220 5221
## 1 3 3 3 3 3 3 3 3 2 3 3 3
## 5222 5223 5225 5227 5228 5230 5231 5232 5234 5235 5236 5237 5238
## 3 3 3 3 1 1 1 1 3 3 3 3 3
## 5240 5241 5242 5243 5244 5246 5247 5248 5250 5251 5252 5253 5254
## 3 3 3 2 2 3 3 3 3 3 3 3 3
## 5256 5258 5259 5260 5262 5263 5266 5267 5268 5271 5275 5276 5277
## 3 3 1 3 3 3 3 3 3 3 3 1 1
## 5278 5279 5282 5283 5287 5288 5289 5309 5329 5330 5333 5334 5355
## 3 1 3 3 3 1 1 3 3 3 1 3 1
## 5368 5369 5374 5376 5378 5382 5387 5393 5394 5396 5397 5399 5405
## 3 2 3 2 3 1 2 1 2 1 3 1 3
## 5408 5410 5412 5414 5415 5417 5428 5430 5435 5439 5444 5446 5453
## 3 2 1 3 1 1 1 1 3 2 1 1 3
## 5454 5455 5456 5457 5458 5459 5460 5462 5463 5468 5471 5473 5484
## 3 3 1 3 3 3 3 1 2 3 3 3 3
## 5488 5490 5492 5499 5500 5501 5504 5506 5509 5510 5512 5517 5523
## 1 1 3 1 3 1 1 1 1 3 3 2 1
## 5524 5526 5527 5528 5530 5531 5532 5533 5537 5538 5540 5543 5546
## 1 1 3 1 3 1 1 3 3 1 1 1 3
## 5547 5550 5551 5552 5554 5556 5557 5558 5560 5562 5564 5565 5566
## 3 2 3 3 1 1 1 3 1 1 3 3 3
## 5567 5568 5569 5570 5574 5582 5584 5585 5586 5588 5590 5591 5593
## 2 1 1 3 3 1 1 2 3 2 2 2 1
## 5600 5604 5609 5611 5612 5613 5616 5618 5621 5622 5624 5627 5628
## 3 2 1 2 1 2 2 3 1 3 1 2 1
## 5629 5630 5631 5633 5637 5638 5639 5641 5643 5647 5648 5649 5652
## 3 2 2 1 3 3 1 2 3 1 3 1 1
## 5653 5656 5659 5662 5664 5665 5666 5667 5670 5671 5672 5673 5677
## 2 3 2 3 1 3 1 2 1 1 2 3 2
## 5681 5685 5692 5706 5708 5711 5715 5716 5718 5724 5728 5731 5741
## 2 1 1 3 2 2 3 2 2 1 1 2 3
## 5745 5746 5764 5765 5767 5768 5772 5773 5777 5778 5780 5782 5786
## 1 1 2 1 3 3 1 1 3 1 1 1 1
## 5790 5794 5802 5803 5805 5809 5810 5814 5821 5823 5824 5828 5833
## 1 1 3 1 1 1 3 1 1 2 1 1 1
## 5843 5844 5852 5854 5857 5860 5872 5884 5886 5889 5944 5946 5949
## 1 3 1 1 1 3 3 1 2 1 1 3 1
## 5951 5954 5967 5968 5975 5982 5983 5989 5996 6002 6012 6018 6022
## 1 1 1 1 1 1 3 2 1 1 2 1 1
## 6026 6027 6030 6035 6036 6053 6054 6055 6062 6070 6082 6094 6095
## 2 1 3 2 2 2 2 1 3 1 1 2 1
## 6139 6151 6173 6214 6225 6234 6243 6248 6255 6259 6264 6268 6269
## 3 3 1 3 3 2 1 1 1 3 2 2 3
## 6277 6282 6283 6288 6295 6302 6310 6312 6313 6316 6326 6333 6338
## 2 1 3 1 2 3 1 1 2 3 1 1 1
## 6356 6358 6364 6366 6369 6374 6396 6401 6402 6422 6465 6486 6508
## 1 1 1 1 1 1 1 1 2 3 1 1 1
## 6514 6558 6570 6579 6581 6600 6642 6651 6657 6662 6670 6671 6673
## 1 1 1 3 1 2 1 1 3 1 1 3 2
## 6678 6683 6684 6688 6690 6692 6695 6697 6699 6701 6708 6709 6711
## 2 1 1 1 2 1 2 1 3 3 3 1 3
## 6714 6720 6723 6725 6726 6728 6729 6732 6733 6735 6741 6742 6745
## 1 1 2 2 3 1 1 1 3 1 1 1 3
## 6747 6757 6766 6768 6772 6787 6800 6803 6815 6817 6833 6865 6906
## 1 1 2 1 1 1 1 1 2 1 1 1 1
## 6907 6914 6915 6918 6928 6933 6934 6936 6937 6943 6944 6945 6953
## 1 2 3 1 2 1 1 3 2 1 2 3 2
## 6965 6975 6977 6981 6988 6995 7000 7007 7009 7011 7014 7021 7027
## 1 3 3 1 3 3 1 3 3 3 3 1 2
## 7029 7031 7033 7046 7052 7055 7074 7076 7079 7086 7088 7090 7091
## 3 3 2 1 1 1 2 1 3 3 3 3 1
## 7107 7108 7109 7116 7117 7118 7139 7151 7152 7154 7158 7162 7163
## 2 2 1 1 1 1 1 1 1 2 1 1 1
## 7172 7176 7178 7180 7183 7187 7189 7190 7191 7192 7193 7196 7197
## 1 1 3 1 1 1 2 1 1 1 1 1 1
## 7201 7202 7205 7206 7210 7216 7217 7220 7222 7223 7224 7225 7226
## 1 1 1 2 1 1 1 1 1 3 1 1 3
## 7228 7237 7238 7239 7241 7242 7245 7248 7249 7251 7255 7261 7264
## 1 1 2 1 1 1 1 1 1 1 1 2 1
## 7267 7270 7271 7277 7278 7279 7280 7283 7285 7288 7294 7300 7304
## 2 1 2 1 1 1 1 1 1 3 3 3 2
## 7307 7309 7311 7313 7316 7320 7321 7322 7331 7332 7338 7350 7354
## 1 3 2 1 1 1 1 1 3 1 3 1 1
## 7358 7360 7365 7367 7368 7373 7378 7380 7382 7383 7386 7387 7393
## 1 1 1 1 1 3 3 2 1 1 1 1 1
## 7394 7398 7399 7401 7402 7405 7406 7409 7414 7416 7417 7419 7421
## 2 1 1 1 1 1 1 2 1 1 1 1 1
## 7423 7427 7431 7432 7434 7435 7436 7437 7438 7446 7450 7452 7454
## 1 3 1 1 2 1 1 1 1 1 1 1 1
## 7458 7461 7464 7469 7472 7474 7475 7477 7481 7482 7483 7489 7491
## 1 2 1 1 1 1 3 1 2 1 3 1 1
## 7492 7493 7497 7498 7499 7500 7502 7505 7506 7507 7508 7513 7515
## 1 1 1 1 1 1 2 1 3 3 1 2 1
## 7516 7517 7520 7522 7524 7526 7527 7528 7532 7540 7543 7554 7568
## 1 1 1 1 1 1 1 1 1 1 1 1 1
## 7572 7578 7584 7589 7590 7593 7598 7603 7608 7612 7613 7619 7621
## 1 1 3 1 1 1 1 1 1 2 1 1 1
## 7623 7625 7627 7630 7638 7639 7641 7643 7646 7648 7651 7657 7658
## 1 1 1 3 1 1 1 1 1 1 1 1 1
## 7659 7660 7661 7662 7666 7667 7669 7670 7673 7674 7682 7694 7696
## 1 1 1 1 1 1 3 1 1 1 1 2 3
## 7697 7705 7708 7712 7722 7724 7726 7733 7738 7740 7746 7749 7750
## 3 3 2 2 3 3 3 1 3 3 3 3 2
## 7752 7757 7769 7770 7777 7783 7788 7811 7824 7832 7835 7837 7839
## 3 3 2 3 3 3 3 3 3 1 1 2 1
## 7840 7845 7846 7851 7857 7859 7867 7870 7871 7876 7878 7881 7883
## 1 1 1 2 1 3 3 1 2 1 3 2 3
## 7885 7891 7893 7895 7896 7898 7899 7900 7904 7906 7911 7912 7914
## 1 3 1 1 1 1 1 3 2 2 3 3 3
## 7920 7921 7923 7927 7929 7947 7953 7973 7974 7975 7981 7984 7986
## 2 3 2 2 2 1 3 3 2 2 1 1 1
## 7991 8010 8053 8054 8059 8064 8075 8077 8082 8088 8093 8121 8133
## 1 1 2 1 1 3 3 1 3 1 1 1 1
## 8140 8142 8158 8162 8192 8194 8202 8204 8205 8213 8216 8220 8223
## 1 1 3 1 3 1 3 1 1 1 1 1 2
## 8227 8238 8246 8255 8257 8262 8263 8272 8277 8278 8279 8284 8287
## 3 1 1 1 1 1 1 3 1 1 1 1 2
## 8290 8323 8330 8333 8335 8341 8352 8367 8374 8378 8379 8380 8389
## 1 1 3 1 1 1 1 3 1 3 1 1 1
## 8395 8403 8404 8406 8414 8424 8430 8431 8433 8444 8459 8460 8464
## 1 2 1 1 1 2 1 1 1 1 1 1 1
## 8474 8480 8482 8486 8491 8493 8507 8508 8520 8532 8563 8565 8566
## 1 3 2 2 1 1 3 1 1 2 3 2 3
## 8568 8569 8571 8575 8578 8579 8580 8582 8583 8585 8589 8590 8591
## 1 1 1 3 1 1 2 1 1 3 3 1 1
## 8592 8593 8594 8595 8596 8597 8598 8600 8602 8603 8605 8607 8614
## 3 2 1 3 1 1 1 1 1 3 1 1 1
## 8615 8618 8621 8623 8624 8626 8628 8632 8634 8636 8637 8638 8639
## 2 2 3 1 1 1 1 1 1 1 1 1 3
## 8640 8649 8658 8683 8699 8715 8716 8718 8735 8739 8742 8743 8746
## 1 1 2 1 1 3 1 3 1 1 1 1 1
## 8751 8755 8758 8763 8769 8773 8776 8777 8778 8788 8789 8791 8799
## 1 3 3 1 3 1 1 3 2 1 2 1 2
## 8802 8803 8804 8808 8812 8817 8819 8827 8828 8830 8831 8834 8839
## 1 1 1 1 3 1 1 1 3 2 1 2 3
## 8843 8844 8846 8849 8852 8854 8856 8858 8859 8862 8865 8866 8869
## 1 1 1 1 1 1 3 3 2 1 1 1 1
## 8870 8871 8873 8876 8882 8883 8884 8885 8886 8891 8892 8898 8899
## 1 2 1 2 2 1 2 2 1 1 3 3 1
## 8900 8905 8911 8912 8913 8914 8915 8917 8920 8921 8925 8926 8928
## 1 1 1 1 1 1 1 2 2 1 2 3 1
## 8930 8935 8936 8938 8939 8944 8947 8948 8951 8957 8968 8971 8973
## 3 2 1 1 2 1 2 3 3 1 1 1 3
## 8974 8992 8996 8997 8999 9015 9018 9023 9024 9033 9051 9062 9065
## 1 1 1 3 1 3 1 1 3 1 3 2 1
## 9082 9092 9095 9099 9106 9109 9113 9114 9127 9128 9130 9131 9134
## 1 1 1 3 1 2 3 2 1 1 2 1 1
## 9135 9137 9144 9147 9149 9151 9155 9164 9166 9169 9170 9172 9177
## 2 1 3 2 3 1 1 2 2 1 1 3 2
## 9183 9186 9187 9190 9192 9193 9196 9198 9199 9202 9208 9210 9212
## 1 1 2 1 1 2 1 1 3 2 1 1 2
## 9214 9220 9223 9224 9228 9230 9231 9233 9235 9239 9246 9248 9251
## 1 1 1 3 1 2 1 2 3 1 1 2 1
## 9253 9254 9263 9266 9267 9270 9272 9276 9277 9281 9285 9287 9294
## 1 1 1 1 3 3 2 1 1 3 2 2 2
## 9298 9302 9305 9306 9311 9315 9316 9317 9322 9323 9324 9325 9327
## 1 1 1 1 1 1 2 2 2 2 2 2 3
## 9328 9329 9330 9331 9333 9334 9336 9338 9341 9343 9346 9351 9352
## 1 3 3 1 1 2 1 2 2 2 1 1 2
## 9356 9360 9361 9364 9367 9369 9375 9376 9378 9388 9399 9400 9401
## 3 1 3 1 1 1 1 1 2 1 2 1 3
## 9408 9413 9415 9416 9418 9423 9426 9428 9434 9435 9441 9442 9443
## 1 2 2 2 1 1 3 1 1 1 1 2 3
## 9444 9447 9448 9459 9461 9463 9465 9467 9469 9474 9482 9485 9486
## 1 2 2 1 1 3 1 1 1 1 2 1 2
## 9488 9490 9491 9492 9493 9494 9495 9496 9498 9499 9502 9505 9511
## 1 1 2 2 1 2 1 2 2 2 3 1 2
## 9512 9514 9517 9530 9535 9539 9545 9548 9550 9551 9557 9562 9564
## 2 3 1 1 1 2 1 3 2 1 1 1 3
## 9568 9569 9574 9576 9585 9589 9590 9592 9603 9604 9612 9617 9644
## 3 3 3 1 1 1 1 1 2 1 1 1 1
## 9656 9666 9668 9681 9692 9703 9707 9709 9715 9718 9719 9726 9732
## 1 1 1 1 3 3 3 1 2 3 2 3 1
## 9735 9738 9748 9755 9759 9763 9766 9768 9776 9779 9780 9788 9792
## 3 1 2 1 3 1 1 1 1 1 2 3 1
## 9795 9797 9802 9803 9814 9815 9818 9826 9827 9829 9830 9836 9837
## 3 3 3 1 3 2 1 1 3 1 3 1 3
## 9838 9840 9842 9844 9845 9846 9848 9851 9853 9854 9856 9857 9859
## 1 1 2 2 3 1 3 2 3 1 1 1 3
## 9861 9864 9865 9868 9869 9870 9874 9879 9883 9884 9885 9888 9889
## 1 1 3 1 2 3 2 3 1 3 2 1 1
## 9894 9898 9899 9903 9910 9914 9920 9922 9923 9924 9925 9926 9928
## 1 3 3 1 3 2 1 2 2 1 3 1 1
## 9929 9931 9932 9935 9937 9938 9942 9950 9954 9957 9958 9959 9960
## 3 1 1 1 3 3 1 2 3 1 1 3 3
## 9961 9962 9964 9966 9967 9974 9978 9980 9981 9986 9993 10002 10008
## 3 1 2 1 1 2 3 2 3 1 3 1 2
table(clara_clusters$clustering)
##
## 1 2 3
## 1349 458 702
fviz_cluster(object = clara_clusters, ellipse.type = "t", geom = "point",
pointsize = 1.5) + theme_bw() +
labs(title = "Resultados clustering CLARA") +
theme(legend.position = "none")
# Métodos de clasificación Jerárquica
datj <- scale(df_seitan[,-1])
rownames(datj) <- df_seitan[,1]
# Matriz de distancias euclideas
mat_dist <- dist(x = datj, method = "euclidean")
# Dendrogramas con linkage complete y average
hc_euclidea_complete <- hclust(d = mat_dist, method = "complete")
hc_euclidea_average <- hclust(d = mat_dist, method = "average")
hc_euclidea_single <- hclust(d = mat_dist, method = "single")
hc_euclidea_ward.D2 <- hclust(d = mat_dist, method = "ward.D2")
hc_euclidea_median <- hclust(d = mat_dist, method = "median")
hc_euclidea_centroid <- hclust(d = mat_dist, method = "centroid")
hc_euclidea_mcquitty <- hclust(d = mat_dist, method = "mcquitty")
cor(x = mat_dist, cophenetic(hc_euclidea_complete))
## [1] 0.5287793
cor(x = mat_dist, cophenetic(hc_euclidea_average)) ## Tiene la mayor correlación
## [1] 0.7419524
cor(x = mat_dist, cophenetic(hc_euclidea_single))
## [1] 0.5777365
cor(x = mat_dist, cophenetic(hc_euclidea_ward.D2))
## [1] 0.6857101
cor(x = mat_dist, cophenetic(hc_euclidea_median))
## [1] 0.451545
cor(x = mat_dist, cophenetic(hc_euclidea_centroid))
## [1] 0.7133198
cor(x = mat_dist, cophenetic(hc_euclidea_mcquitty))
## [1] 0.557649
set.seed(101)
hc_euclidea_av <- hclust(d = dist(x = datj, method = "euclidean"), method = "average")
n_groups <- length(unique(hc_euclidea_av$order)) # Obtener el número de grupos en el dendrograma
fviz_dend(x = hc_euclidea_av, k = 2, cex = 0.5,
k_colors = c("red", "green"), color_labels_by_k = TRUE,
lwd = 0.2, type = "c", label_cols = rainbow(n_groups),
rect_lty = "lightblue") +
geom_hline(yintercept = 3.65, linetype = "dashed", color = "blue") +
labs(title = "Hierarchical clustering",
subtitle = "Euclidean Distance, Centroid, k = 2")
## Warning: Removed 1 rows containing missing values (`geom_hline()`).
set.seed(101)
hc_euclidea_av <- hclust(d = dist(x = datj, method = "euclidean"), method = "average")
n_groups <- length(unique(hc_euclidea_av$order)) # Obtener el número de grupos en el dendrograma
fviz_dend(x = hc_euclidea_av, k = 3, cex = 0.5,
k_colors = c("red", "green", "orange"), color_labels_by_k = TRUE,
lwd = 0.2, type = "c", label_cols = rainbow(n_groups),
rect_lty = "lightblue") +
geom_hline(yintercept = 3.65, linetype = "dashed", color = "blue") +
labs(title = "Hierarchical clustering",
subtitle = "Euclidean Distance, Centroid, k = 3")
## Warning: Removed 1 rows containing missing values (`geom_hline()`).
set.seed(101)
hc_euclidea_av <- hclust(d = dist(x = datj, method = "euclidean"), method = "average")
n_groups <- length(unique(hc_euclidea_av$order))
# Definir colores personalizados para 4 clusters
cluster_colors <- c("red", "green", "blue", "orange")
# Crear vector de colores etiquetados por observación
label_colors <- rep(cluster_colors, length.out = n_groups)
# Graficar el dendrograma con colores personalizados
fviz_dend(x = hc_euclidea_av, k = 4, cex = 0.5,
lwd = 0.2, type = "c", label_cols = label_colors,
rect_lty = "lightblue") +
geom_hline(yintercept = 3.65, linetype = "dashed", color = "blue") +
labs(title = "Hierarchical clustering",
subtitle = "Euclidean Distance, Centroid, k = 4")
## Warning: Removed 1 rows containing missing values (`geom_hline()`).